<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>

<body>
    <div id="username"></div>
    <div id="password"></div>

    <script>
        function login(){
            jQuery.ajax({
                type:"POST",
                url: "/user/login",
                data:{"username": jQuery("#username").val(),"password": jQuery("#password").val()},
                success:function(result){
                    // 回调函数
                    if(result.code == 200 && result.data != null){
                        // 在浏览器中存储 token
                        localStorage.setItem("user_token",result.data);
                        // 登录成功后，可以跳转到主页面 ... 
                    }else{
                        alert("登录失败！")
                        return;
                    }
                }
            });
        }

       
    </script>
</body>

</html>